/**
 * export-util
 */

/**
 * 导出流文件
 * @param res
 * @param fileName
 */
export function downLoadMix (res, fileName) {
  let blob = new Blob([res]); //res为从后台返回的数据
  if (!fileName) {
    fileName = res.headers["content-disposition"].split("filename=").pop();
  }
  if ("msSaveOrOpenBlob" in navigator) {
    window.navigator.msSaveOrOpenBlob(blob, fileName);
  } else {
    const elink = document.createElement("a");
    elink.download = fileName;
    elink.style.display = "none";
    elink.href = URL.createObjectURL(blob);
    document.body.appendChild(elink);
    elink.click();
    URL.revokeObjectURL(elink.href);
    document.body.removeChild(elink);
  }
}
